package com.example.demo.sevice.imp;

import antlr.StringUtils;
import com.example.demo.controller.data.ReturnData;
import com.example.demo.dao.BannerDao;
import com.example.demo.entity.Banner;
import com.example.demo.sevice.BannerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Timestamp;

@Service
public class BannerServiceImp implements BannerService {
    @Resource
    BannerDao bannerDao;
    @Override
    public ReturnData getBanner() {
        return ReturnData.ok(bannerDao.findAll());
    }
    @Override
    public ReturnData addBanne(Banner banner){
        if (banner.getId()==0){
            banner.setAddTime(new Timestamp(System.currentTimeMillis()));
            banner.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        }else {
            banner.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        }

    }
}
